import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:f_demo/models/models.dart';
import 'package:f_demo/res/config.dart';

class TabPage extends StatefulWidget {
  @override
  _TabPageState createState() => _TabPageState();
}

class _TabPageState extends State<TabPage> {
  int _index = 0;

  void _pushTab(index) {
    setState(() {
      _index = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: Container(
        margin: EdgeInsets.all(5),
        width: ScreenUtil().setHeight(110),
        height: ScreenUtil().setHeight(110),
        decoration: BoxDecoration(
            shape: BoxShape.circle,
            color: Theme.of(context).primaryColor,
            boxShadow: [
              BoxShadow(
                  color: Color.fromRGBO(150, 150, 150, 1),
                  offset: Offset(0, 5),
                  blurRadius: 5,
                  spreadRadius: 1)
            ]),
        child: Icon(
          Icons.add,
          color: Colors.white,
          size: 30,
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      bottomNavigationBar: BottomAppBar(
        shape: CircularNotchedRectangle(),
        child: BottomNavigationBar(
          currentIndex: _index,
          onTap: (index) {
            _pushTab(index);
          },
          elevation: 0,
          backgroundColor: Colors.transparent,
          items: tabs.map((TabModel tab) {
            return BottomNavigationBarItem(
                title: Text(tab.title), icon: tab.icon);
          }).toList(),
        ),
      ),
      body: tabs[_index].page,
//      body: IndexedStack(
//        index: _index,
//        children: tabs.map((TabModel tab) => tab.page).toList(),
//      ),
    );
  }
}
